package com.sam.im.heiqun.uis.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sam.im.heiqun.R;
import com.sam.im.heiqun.app.App;
import com.sam.im.heiqun.utils.ToolsUtils;
import com.yuyh.library.uis.activitys.BaseSwipeBackActivity;
import com.sam.im.heiqun.utils.ToolsUtils;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by wangguodong on 2017/9/6.
 */

public class AcountSecurityActivity extends BaseSwipeBackActivity {

    @BindView(R.id.alter_psd)
    LinearLayout alter_psd;
    @BindView(R.id.alter_pay_psd)
    LinearLayout alter_pay_psd;
    @BindView(R.id.real_name_approve)
    LinearLayout real_name_approve;

    @BindView(R.id.tx_Phone_number)
    TextView tx_Phone_number;

    public static void start(Activity activity ){
        Intent intent = new Intent(activity, AcountSecurityActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected String getTitleText() {
        return getResources().getString(R.string.account_security);
    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        PhoneNumber();
    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_account_security_set;

    }
  public void PhoneNumber(){
    String ss=ToolsUtils.getUser().getMobile();
    tx_Phone_number.setText(ss);
  }
    @OnClick({R.id.alter_psd, R.id.alter_pay_psd, R.id.real_name_approve})
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.pre_v_back:
                scrollToFinishActivity();
                break;
            case R.id.alter_psd:
                intent = new Intent(this, NewPasswordActivity.class);
                intent.putExtra("type", getResources().getString(R.string.alter_psd));
                startActivity(intent);
                break;
            case R.id.alter_pay_psd:
                intent = new Intent(this, NewPasswordActivity.class);
                intent.putExtra("type", getResources().getString(R.string.set_pay_psd));
                startActivity(intent);
                break;
            case R.id.real_name_approve:
                if (ToolsUtils.getUser().getIsAuth()==0){
                    startActivity(AutoCheckActvity.class);
                }else {
                    showToast(getResources().getString(R.string.renzheng_old));
                }
                break;
        }
    }

    /**
     * 做 退出登录 操作
     */
    public void doExit() {
        //App.userEntivity.delete();//从数据库中删除登录信息
        //App.userEntivity = null;//清除之前登陆的数据
        App.isManualLogout = true;
        Intent intent = new Intent(this, LoginActivity.class);
        ToolsUtils.saveLoginstate(this,false,1);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        //  stopService(new Intent(PrivacyActivity.this,AcceptService.class));
        //先断掉连接，然后关闭socket
        if (App.getInstance().getSocket() != null) {
            App.getInstance().getSocket().disconnect();
            App.getInstance().getSocket().close();
            App.socket=null;
        }
        startActivity(intent);
        finish();


    }

}
